
import sys
import os

file_path = os.path.abspath(__file__)
end = file_path.index('qmt_auto_trade') + 17
project_path = file_path[0:end]
sys.path.append(project_path)


import mk_common.component.qmt.qmt_auto_login_service as qmt_auto_login_service
import config.config_service as config_service

import push.push_msg_service as push_msg_service


def qmt_auto_login():
    config_info_dict = config_service.get_config_info()
    qmt_account_no = config_info_dict.get('qmt_account_no')
    qmt_account_password = config_info_dict.get('qmt_account_password')
    qmt_exe_path = config_info_dict.get('qmt_exe_path')

    login_flag = qmt_auto_login_service.check_qmt_status(str(qmt_account_no),
                                                         str(qmt_account_password),
                                                         qmt_exe_path)

    if bool(1 - login_flag):
        #
        title = "qmt自动登录失败"
        msg = "qmt客户端自动登录失败,请手动登录"

        push_msg_service.push_msg(title, msg)


if __name__ == '__main__':
    qmt_auto_login()
